////
////  CheckScanViewController.swift
////  AESOLAR_IOS
////
////  Created by Mr.Wang on 2019/10/17.
////  Copyright © 2019 Mr.Wang. All rights reserved.
////
//
//import UIKit
//
//class CheckScanViewController: BaseUIViewController {
//
//    var locationUnit: LocationUnit?
//
//    override func viewDidLoad() {
//        super.viewDidLoad()
//        self.navigationItem.title = "江苏新源".localized
//
//        let imageView = UIImageView().config
//            .contentMode(.scaleToFill)
//            .addTo(self.view)
//            .makeConstraints { (make) in
//                make.left.top.right.equalToSuperview()
//                make.height.equalTo(SCREEN_WIDTH * 0.693)
//        }.view
//
//        let tipLabel = UILabel().config
//            .text("请将手机摄像头对准条形码".localized)
//            .textColor(APPConfig.baseColor)
//            .textAlignment(.center)
//            .font(.systemFont(ofSize: 16, weight: .medium))
//            .numberOfLines(0)
//            .addTo(view)
//            .makeConstraints { (make) in
//                make.centerX.equalToSuperview()
//                make.top.equalTo(imageView.snp.bottom)
//                make.width.equalTo(SCREEN_WIDTH * 0.9)
//        }.view
//
//        let checkButton = UIButton().config
//            .cornerRadius(22)
//            .masksToBounds(true)
//            .backgroundImage(UIImage.imageWithColor(APPConfig.baseColor))
//            .title("快速查验".localized)
//            .addTarget(self, action: #selector(scan))
//            .titleColor(.white)
//            .addTo(view)
//            .makeConstraints { (make) in
//                make.centerX.equalToSuperview()
//                make.top.equalTo(tipLabel.snp.bottom).offset(40)
//                make.height.equalTo(44)
//                make.width.equalTo(180)
//        }.view
//
//        UIButton().config
//            .cornerRadius(22)
//            .masksToBounds(true)
//            .borderColor(APPConfig.baseColor)
//            .borderWidth(0.9)
//            .backgroundImage(UIImage.imageWithColor(#colorLiteral(red: 0.992969811, green: 0.992969811, blue: 0.992969811, alpha: 1)))
//            .backgroundImage(UIImage.imageWithColor(#colorLiteral(red: 0.8573158979, green: 0.8573158979, blue: 0.8573158979, alpha: 1)), for: .highlighted)
//            .title("切换NFC查验".localized)
//            .titleColor(APPConfig.baseColor)
//            .addTarget(self, action: #selector(change))
//            .addTo(view)
//            .makeConstraints { (make) in
//                make.centerX.equalToSuperview()
//                make.top.equalTo(checkButton.snp.bottom).offset(15)
//                make.height.equalTo(44)
//                make.width.equalTo(180)
//        }
//
//        if let path = Bundle.main.path(forResource: "scan.gif", ofType: nil),
//            let data = try? Data.init(contentsOf: URL.init(fileURLWithPath: path)) {
//            imageView.image = UIImage.sd_tz_animatedGIF(with: data)
//        }
//
//    }
//
//    @objc func scan() {
//        locationUnit = LocationUnit()
//        locationUnit?.showLoading = true
//        locationUnit?.takeOnce = true
//
//        locationUnit?.addressRefuseClosure = { [weak self] in
//                 self?.scanCode()
//            self?.locationUnit = nil
//        }
//        locationUnit?.addressUpdate = { [weak self] address in
//            let longitude = self?.locationUnit?.longitude
//            let latitude = self?.locationUnit?.latitude
//                self?.scanCode(longitude: longitude,
//                               latitude: latitude,
//                               address: address)
//            self?.locationUnit = nil
//        }
//        locationUnit?.settingClosure = { [weak self] in
//            self?.locationUnit = nil
//        }
//        locationUnit?.startLocation()
//    }
//
//    func scanCode(longitude: String? = nil, latitude: String? = nil, address: String? = nil) {
//        let vc = ScanVerifyViewController()
//        vc.successClosure = { code in
//            ApiManager.scanVerify(code, longitude: longitude ?? "", latitude: latitude ?? "", address: address ?? "")
//                .request()
//                .filterCode200()
//                .dataModelMap(CheckModel.self)
//                .trackingLoading()
//                .subscribe(onNext: { [weak self] (result) in
//                    if result.result.isSuccess {
//                        self?.navigationController?.pushTo(SuccessViewController(result: result.psrInfo), remove: 1)
//                    } else {
//                        let vc = FailureViewController(psrCheckId: result.id)
//                        self?.navigationController?.pushTo(vc, remove: 1)
//                    }
//                }).disposed(by: self.rx.disposeBag)
//        }
//        self.navigationController?.pushViewController(vc, animated: true)
//    }
//
//    @objc func change() {
//        let vc = CheckNFCViewController()
//        self.navigationController?.pushTo(vc, remove: 1)
//    }
//
//    override func navigationBarStyle() -> NavigationBarStyle {
//        return .baseColor
//    }
//}
